package com.gry.stusys;

import java.util.ArrayList;
import java.util.Random;

public class Test {
    public static void main(String[] args) {
        System.out.println(verificationCode());
    }
    private static String verificationCode(){
        ArrayList<Character> list = new ArrayList<>();
        for (int i = 0; i < 26; i++) {
            list.add((char) ('a' + i));
            list.add((char) ('A' + i));
        }
        Random r = new Random();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < 4; i++) {
            int index = r.nextInt(list.size());
            char c = list.get(index);
            sb.append(c);
        }
        sb.append(r.nextInt(10));
        char[] charArray = sb.toString().toCharArray();
        int index = r.nextInt(charArray.length);
        char temp = charArray[index];
        charArray[index] = charArray[charArray.length-1];
        charArray[charArray.length-1] = temp;
        return new String(charArray);

    }
}
